package com.universe.demo.springboot.filedemo;

import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.read.listener.ReadListener;

import java.util.List;

public class UserDataListener implements ReadListener<UserData> {

    private List<UserData> userDataList;

    public UserDataListener(List<UserData> userDataList) {
        this.userDataList = userDataList;
    }

    @Override
    public void invoke(UserData data, AnalysisContext context) {
        // 每解析一行数据调用一次
        userDataList.add(data);
    }

    @Override
    public void doAfterAllAnalysed(AnalysisContext context) {
        // 全部数据解析完毕后调用
    }
}
